<template>
    <div>
        <!-- 其他模块 -->
        <ul class="other-module-list clearfix" style="position: absolute;top: -30px;left: 157px;">
            <li v-for="(item,index) in otherlist" :key="index" @click="otherFun(index)">
                <a href="javascript:;">{{item}}</a>
            </li>
        </ul>
        <div class="content-left-box" style="position: absolute;left: -231px;top: 0px;">
            <!-- 账户信息 -->
            <Accountinfo @refresh="refreshFun" :openBet="openBet" :ninetime="ninetime" :refreshaccount="refreshaccount" />
            <!-- 开奖结果 -->
            <Gameresult @refreshed="refreshedFun" :refreshState="refreshState" :openBet="openBet" :ninetime="ninetime" />
            <!-- 最新注单 -->
            <NewBet :openBet="openBet" :ninetime="ninetime" :newbetData="newbetData" />
        </div>
        <div>
            <!-- 票种 -->
            <div v-if="otherind == -1">
                <!-- 票种info（倒计时） -->
                <Gamehead @noBet="noBetFun" @openBet="openBetFun" @ninetime="ninetimeFun" />
                <!-- 赔率 -->
                <div>
                     <!-- 广东快乐十分、重庆幸运农场 -->
                    <Gdklsfgame @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 14 || id == 15" />
                    <!-- 山东11选5、广东11选5、江西11选5 -->
                    <SdChoose @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 11 || id == 12 || id == 13" />
                    <!-- 安徽快3、江苏快3 -->
                    <Quick @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 9 || id == 10 || id == 16" />
                    <!-- 时时彩 -->
                    <Ssc @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 6 || id == 7 || id == 8" />
                    <!-- 北京快乐8 -->
                    <Bjkl @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 4" />
                    <!-- 北京PK拾、幸运飞艇 -->
                    <Xyft @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 3 || id == 5" />
                    <!-- 六合彩 -->
                    <Lhc @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 2" />
                    <!-- PC蛋蛋 -->
                    <Pcdd @betdataObj="betdataObj" @contBetObj="contBetObj" :ninetime="ninetime" :betmoney="betmoney" :resetinp="resetinp" :openBet="openBet" v-if="id == 1" />

                    <!-- 快捷下注 -->
                    <Quickbet @moneyfocusFun="moneyfocusFun" @resetsFun="resetinpFun" @betsuccess="betsuccessFun" :betdata="betdata" :contBetData="contBetData" :noBet="noBet" :openBet="openBet" />

                </div>
                <!-- 路珠 -->
                <Gamefoot :openBet="openBet" :ninetime="ninetime" />
            </div>
            <!-- 其他模块内容 -->
            <div v-else>
                <!-- 即时注单 -->
                <NoteList v-if="otherind == 0" />
                <!-- 下注历史 -->
                <BetHistory v-if="otherind == 1" />
                <!-- 开奖结果 -->
                <LotteryResults v-if="otherind == 2" />
                <!-- 个人资讯 -->
                <Information v-if="otherind == 3" />
                <!-- 游戏规则 -->
                <GameRules v-if="otherind == 4" />
                <!-- 财务管理 -->
                <FinancialManagement v-if="otherind == 5 && deal_type == 1" />
                <!-- 修改密码 -->
                <ChangePassword v-if="(deal_type == 2 && otherind == 5) || (deal_type == 1 && otherind == 6)" />
            </div>
            
        </div>
        <div>
            <!-- 双面长龙 -->
            <LongDragon :openBet="openBet" :ninetime="ninetime" />
        </div>
        

    </div>
</template>
<style>
    html,body{
        background: #fff!important;
    }
</style>
<script>
    
    export default {
        data(){
            return{
                betmoney: '',  //下注金额
                id: 0,  //票种id
                resetinp: 0,  //是否重填已下注  0为未下注  其他为已下注
                betdata: {},  //下注提交数据
                contBetData: {},  //连码下注
                noBet: false,  //不可下注
                openBet: false,  //可下注  请求
                ninetime: 0,  //90秒

                refreshState: false,  //刷新
                newbetData: [],  //最新注单  数据

                otherlist: [],
                otherind: -1,
                refreshaccount: 0,
                deal_type: 0,
            }
        },
        methods: {
            init(){
                // console.log(this.$route.query);
                //id 为票种id    levelid 为票种分类id
                
                this.id = this.$route.query.id;
                this.deal_type = window.localStorage.deal_type;
                if(window.localStorage.deal_type == 1){  //现金

                    this.otherlist = ['即时注单','下注历史','开奖结果','个人资讯','游戏规则','财务管理','修改密码','安全退出'];

                }else if(window.localStorage.deal_type == 2){  //信用

                    this.otherlist = ['即时注单','下注历史','开奖结果','个人资讯','游戏规则','修改密码','安全退出'];

                }
                
            },
            //从子组件  接取快捷下注金额值
            moneyfocusFun(betmoneys){
                
                this.betmoney = betmoneys;
            },
            //重填已下注的金额
            resetinpFun(){
                this.resetinp++;
            },
            betdataObj(data){
                // console.log('gamedetail',data);
                this.betdata = data;
            },
            contBetObj(obj){
                // console.log(obj);
                this.contBetData = obj;
            },
            noBetFun(){
                // 不可下注
                //  console.log('不可下注');
                this.noBet = true;
            },
            openBetFun(){
                // 可下注  请求开奖（赔率）、账户信息、开奖结果、两面长龙接口、路珠（beadCount）接口
                //  console.log('刷新');
                this.openBet = true;
                this.$emit('parentopen');
            },
            ninetimeFun(){
                // 90秒 账户信息、开奖结果、两面长龙、路珠（beadCount）接口
                // console.log('90s');
                this.ninetime++;
            },
            //刷新账户信息、开奖结果
            refreshFun(){
                this.refreshState = true;
            },
            //最新下注
            betsuccessFun(data){
                // console.log('-------最新注单--------',data);
                this.newbetData = data;
                this.refreshaccount++;
            },
            //已刷新过一次开奖结果
            refreshedFun(){
                this.refreshState = false;
            },
            //其他模块
            otherFun(ind){

                if(window.localStorage.deal_type == 1){  //现金
                    var num = 7;
                }else if(window.localStorage.deal_type == 2){  //信用
                    var num = 6;
                }
                if(ind != num){
                    this.otherind = ind;
                }else if(ind == num){  //安全退出

                    var mymessage=confirm('您确定退出吗？');
                            
                    if(mymessage==true){
                        var clearInfo = window.localStorage.clear();
                        top.location.href = top.location.href;
                    }
                }
            },
            
        },
        mounted(){
            this.init();
        },
    }
</script>
